﻿@model MvcGraduate.Models.Account

@{
    ViewBag.Title = "Register";
    Layout = "~/Views/Shared/Login_Layout.cshtml";
}


<div style="height: 390px;width: 100%;background-image:url(../../Images/login-bg.png);">
    <form name="formSub" action="@Url.Action("Register")" method="post">
        <table style="margin-left:220px;">
            <tr>
                <td></td>
            </tr>
            <tr>
                <td></td>
            </tr>
            <tr>
                <td align="right" style="color:#000;">用户名：</td>
                <td><input name="name" id="name" required="required" class="Input_Register" style="background-image: url('../../Images/name.png');" placeholder="请输入账户..." /></td>
                <td align="left" style="color:#333333;padding-left:4px"><label for="name" id="Error_Name"></label></td>
            </tr>
            <tr>
                <td align="right" style="color:#000;">邮箱：</td>
                <td><input name="email" required="required" email="true" class="Input_Register" style="background-image: url('../../Images/email.png');" placeholder="请输入邮箱..." /></td>
                <td align="left" style="color:#333333;padding-left:4px">@Html.ValidationMessage("email")</td>
            </tr>
            <tr>
                <td align="right" style="color:#000;">密 码：</td>
                <td><input name="pwd" required="required" id="pwd" class="Input_Register" type="password" style="background-image: url('../../Images/pwd.png');" placeholder="请输入密码..." /></td>
                <td align="left" style="color:#333333;padding-left:4px">@Html.ValidationMessage("pwd")</td>
            </tr>
            <tr>
                <td align="right" style="color:#000;">确认密码：</td>
                <td><input class="Input_Register" name="reaptpwd" type="password" equalTo="#pwd" style="background-image: url('../../Images/pwd.png');" placeholder="请再次输入密码..." /></td>
                <td align="left" style="color:#333333;padding-left:4px">@Html.ValidationMessage("reaptpwd")</td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" style="width:40%" value="立即注册" onclick="validateAccountExist()" class="btn" /></td>
                <td></td>
            </tr>
        </table>
    </form>
</div>
<script>
    function validateAccountExist()
    {
        $.post(
            "@Url.Action("IsHaveCountWithoutCode")",
            { loginID: $('#name').val()},
            function (data) {
                if (data != 0) {
                    $('#Error_Name').text("用户或邮箱已存在");
                }
                else {
                    document.formSub.submit();
                }
            });
    }
</script>